package com.qzimp.fujiancuo.service.impl;

import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.qzimp.fujiancuo.entity.UserLikes;
import com.qzimp.fujiancuo.mapper.UserLikesMapper;
import com.qzimp.fujiancuo.service.UserLikesService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 *  服务层实现。
 *
 * @author 梁少君
 * @since 2024-12-21
 */
@Service
public class UserLikesServiceImpl extends ServiceImpl<UserLikesMapper, UserLikes> implements UserLikesService {

    @Resource
    private UserLikesMapper userLikesMapper;

    @Override
    public UserLikes findByUserIdAndCuoId(Integer userId, Integer cuoId) {
        //构建条件查询符合条件的一条
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("user_id",userId);
        queryWrapper.eq("cuo_id",cuoId);
        return userLikesMapper.selectOneByQuery(queryWrapper);
    }

    @Override
    public List<UserLikes> findAllByUserId(Integer userId) {
        //查询该用户所有的点赞
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("user_id",userId);
        return userLikesMapper.selectListByQuery(queryWrapper);
    }

    @Override
    public List<UserLikes> findAll() {
        //查询全部
        return userLikesMapper.selectAll();
    }
}
